import React, {
  createBrowserRouter,
  createHashRouter,
  RouterProvider,
  redirect,
} from 'react-router-dom'
import AppComment from '../AppComment'
import ChartList from '../components/echartList'
import Layout from '../pages/layout/index'
import About from '../components/about'
import Board from '../components/board'
import PayDetail from '../components/detail'
import Login from '../pages/login/login'
import Cesium from '../pages/cesium/cesium'

//1、创建router实例对象并且配置路由对应关系
const router = createHashRouter([
  {
    index: true,
    // 首页重定向到 /appComment
    loader: () => redirect('/appComment'),
  },
  {
    path: '/login',
    element: <Login />,
  },
  {
    path: '/cesium',
    element: <Cesium />,
  },
  {
    path: '/layout',
    element: <Layout />,
    children: [
      {
        index: true,
        // path:'board',
        element: <Board />,
      },
      {
        path: 'about',
        element: <About />,
      },
      {
        path: 'detail',
        element: <PayDetail />,
      },
    ],
  },
  {
    path: '/appComment',
    element: <AppComment />,
  },
  {
    path: '/article/:id',
    element: <ChartList />,
  },
])

export default router
